﻿using System.Drawing;
using GraphDrawing2.V2.Concrete.Model;

namespace GraphDrawing2.V2.Concrete.States
{
    public class ViewPortTranslationState : IState
    {
        readonly Model2 model;
        Point prevPoint;

        public ViewPortTranslationState(Model2 model)
        {
            this.model = model;
            prevPoint = model.CanvasModel.MousePosition;
        }

        public void ProcessMouseMove()
        {
            var currentPoint = model.CanvasModel.MousePosition;
            var viewPort = model.ViewPort;
            var dx = (currentPoint.X - prevPoint.X) / viewPort.Scale;
            var dy = (currentPoint.Y - prevPoint.Y) / viewPort.Scale;
            viewPort.Move(dx, dy);
            prevPoint = currentPoint;
        }

        public void ProcessMouseUp()
        {
        }

        public void ProcessKeyPressed()
        {
        }
    }
}